package com.nearby.demand.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.drawee.view.SimpleDraweeView;
import com.nearby.demand.R;
import com.nearby.demand.db.Demand;
import com.nearby.demand.utils.KLog;
import com.nearby.demand.utils.WindowUtil;

import java.util.List;

/**
 * Created by lizhangqu on 2015/6/home_3.
 */
public class MyAdapter extends BaseRecyclerViewAdapter<Demand, MyAdapter.MyViewHolder> {

    public MyAdapter(List<Demand> list) {
        super(list);
    }


    @Override
    protected void bindDataToItemView(MyViewHolder myViewHolder, Demand item) {
        KLog.i("TAG",item.getStBg());
        int height = WindowUtil.getScreenHeight();
        int width = WindowUtil.getScreenWidth();
        SimpleDraweeView simpleDraweeView = (SimpleDraweeView) myViewHolder.getView(R.id.sdview);
        myViewHolder.setText(R.id.tv_show,item.getStLabel());
        simpleDraweeView.setLayoutParams(new FrameLayout.LayoutParams(width, height / 3));
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setUri(item.getStBg())
                .build();

        simpleDraweeView.setController(controller);
    }


    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int type) {

        return new MyViewHolder(inflateItemView(viewGroup, R.layout.ui_world_item));


    }


    public class MyViewHolder extends BaseRecyclerViewAdapter.SparseArrayViewHolder {

        public MyViewHolder(View itemView) {
            super(itemView);

        }


    }

}
